package com.babster631;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityEnderPearl;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemEnderPearl;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class thunderpearl extends ItemEnderPearl 
{
    public thunderpearl(int par1) {
            super(par1);
            this.setCreativeTab(CreativeTabs.tabMisc);
    }
    
    public void registerIcons(IconRegister iconReg) 
    {
    	itemIcon = iconReg.registerIcon("babster631modbase:ThunderPearl.fw");
    }
    
    /**
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
     */
    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    
    {
        if (par3EntityPlayer.capabilities.isCreativeMode)
        {
            return par1ItemStack;
        }
        else if (par3EntityPlayer.ridingEntity != null)
        {
            return par1ItemStack;
        }
        else
        {
            --par1ItemStack.stackSize;
            par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

            if (!par2World.isRemote)
            {
            	
            	//This is used to create a thunderpearl that knocks back all mobs in the area
            	EntityThunderPearl pearl = new EntityThunderPearl(par2World, par3EntityPlayer);
            	pearl.User = par3EntityPlayer;
                par2World.spawnEntityInWorld(new EntityEnderPearl(par2World, par3EntityPlayer));
                par2World.spawnEntityInWorld(pearl);
                
              
            }

            return par1ItemStack;
        }
    }
}